package com.example.oa;

import org.apache.commons.dbcp.BasicDataSource;

import java.sql.Connection;
import java.sql.SQLException;

public class DB {
    private static final BasicDataSource BASIC_DATA_SOURCE = new BasicDataSource();
    static {
        // BASIC_DATA_SOURCE.setUrl(jdbc:mysql:///?serverTimezone=UTC);
        BASIC_DATA_SOURCE.setDriverClassName("com.mysql.jdbc.Driver");
        BASIC_DATA_SOURCE.setUrl("jdbc:mysql:///?serverTimezone=UTC");
        BASIC_DATA_SOURCE.setUsername("root");
        BASIC_DATA_SOURCE.setPassword("root");

    }
    public static Connection getConnect(){
        try {
            return BASIC_DATA_SOURCE.getConnection();
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }

    public static void main(String[] args) {
        System.out.println(getConnect());
    }
}
